﻿using AnyTap.Models;
using ScreenToGif.Native.External;
namespace AnyTap;

public class TapAccessibilityService
{
	public static bool Gesture(TapGesture arg)
	{
		switch(arg.Type)
		{
		case GestureType.Move:
			User32.SetCursorPos((int)arg.X, (int)arg.Y);
			break;
		case GestureType.MouseWheel:
			User32.mouse_event(ScreenToGif.Native.Constants.MOUSEEVENTF_WHEEL, 0, 0, (int)arg.Y, 0);
			break;
		case GestureType.MouseLeftDown:
			User32.SetCursorPos((int)arg.X, (int)arg.Y);
			User32.mouse_event(ScreenToGif.Native.Constants.MOUSEEVENT_LEFTDOWN, (int)arg.X, (int)arg.Y, 0, 0);
			break;
		case GestureType.MouseLeftUp:
			User32.mouse_event(ScreenToGif.Native.Constants.MOUSEEVENT_LETFUP, (int)arg.X, (int)arg.Y, 0, 0);
			break;
		case GestureType.MouseMiddleDown:
			User32.SetCursorPos((int)arg.X, (int)arg.Y);
			User32.mouse_event(ScreenToGif.Native.Constants.MOUSEEVENTF_MIDDLEDOWN, (int)arg.X, (int)arg.Y, 0, 0);
			break;
		case GestureType.MouseMiddleUp:
			User32.mouse_event(ScreenToGif.Native.Constants.MOUSEEVENTF_MIDDLEUP, (int)arg.X, (int)arg.Y, 0, 0);
			break;
		case GestureType.MouseRightDown:
			User32.SetCursorPos((int)arg.X, (int)arg.Y);
			User32.mouse_event(ScreenToGif.Native.Constants.MOUSEEVENTF_RIGHTDOWN, (int)arg.X, (int)arg.Y, 0, 0);
			break;
		case GestureType.MouseRightUp:
			User32.mouse_event(ScreenToGif.Native.Constants.MOUSEEVENTF_RIGHTUP, (int)arg.X, (int)arg.Y, 0, 0);
			break;
		case GestureType.KeyDown:
			User32.keybd_event((byte)arg.Key, 0, 0, 0);
			break;
		case GestureType.KeyUp:
			User32.keybd_event((byte)arg.Key, 0, ScreenToGif.Native.Constants.KEYEVENTF_KEYUP, 0);
			break;
		default:
			break;
		}

		return true;
	}

}
